package xinxin.com.MediatorPatternBasic.Mediator.Detail;

import xinxin.com.MediatorPatternBasic.Colleague.AbstractColleague;
import xinxin.com.MediatorPatternBasic.Colleague.Detail.ConcreteColleague1;
import xinxin.com.MediatorPatternBasic.Colleague.Detail.ConcreteColleague2;
import xinxin.com.MediatorPatternBasic.Mediator.AbstractMediator;

/**
 * @author ：史鑫鑫
 * @date ：Created in 2019/4/1 20:56
 */
public class ConcreteMediator extends AbstractMediator {
    private ConcreteColleague1 colleague1;
    private ConcreteColleague2 colleague2;

    public void setColleague1(ConcreteColleague1 colleague1) {
        this.colleague1 = colleague1;
    }

    public void setColleague2(ConcreteColleague2 colleague2) {
        this.colleague2 = colleague2;
    }

    @Override
    public void send(String message, AbstractColleague colleague) {
        if (colleague == colleague1) {
            colleague2.notify(message);
        } else {
            colleague1.notify(message);
        }
    }
}
